package com.zc.service.imp;

import com.zc.dao.DemoDao;
import com.zc.domain.po.Demo;
import com.zc.service.DemoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created by zhangchi9 on 2016/11/10.
 */
@Service
public class DemoServiceImpl implements DemoService{

    @Autowired
    private DemoDao demoDao;


    public void addDemo(Demo demo) {
        demoDao.insertDemo(demo);
        String a = null;
        a.toString();
        List<Demo> list = demoDao.selectDemos(demo);
        System.out.println(list.toString());
        System.out.println("add Demo is execure");
    }


    @Transactional(propagation = Propagation.REQUIRED)
    public List<Demo> gainDemo(Demo demo) {
        demoDao.insertDemo(demo);
        String a = null;
        a.toString();
        List<Demo> list = demoDao.selectDemos(demo);
        System.out.println(list.toString());
        return list;
    }
}
